package com.pro.springbootpro.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pro.springbootpro.entity.People;
import com.pro.springbootpro.mapper.PeopleMapper;
import com.pro.springbootpro.service.IPeopleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author DJR (1210843430@qq.com)
 */

@Slf4j
@Service
public class PeopleServiceImpl implements IPeopleService {
    @Autowired
    private PeopleMapper peopleMapper;

    @Override
    public PageInfo<People> getByPage(Integer pageNum,Integer PageSize) {
        PageHelper.startPage(pageNum,PageSize);
        List<People> allPeople = peopleMapper.getAll();
        return new PageInfo(allPeople);
    }

    @Override
    public void save(List<People> peopleList) {
        peopleMapper.save(peopleList);
    }

    @Override
    @Async("asyncPoolTaskExecutor")
    public void asyncTest() {
        log.info("这是一个default异步方法");
    }

    @Override
    public void mainTest() {
        log.info("这是主线程方法");
    }

    @Override
    @Async("djrPoolTaskExecutor")
    public void djrAsyncTest() {
        log.info("这是djr异步线程方法");
    }
}
